//
//  MyNodeShenVC.m
//  digitalCurrency
//
//  Created by 小震GG on 2019/11/1.
//  Copyright © 2019 XinHuoKeJi. All rights reserved.
//

#import "MyNodeShenVC.h"
#import "MyNodeShenKuanCell.h"
#import "NewAllNetManager.h"
@interface MyNodeShenVC ()

@property (nonatomic, strong) NSMutableArray *dataArr;
@property (nonatomic, strong) LYEmptyView *emptyView;

@end

@implementation MyNodeShenVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.dataArr = [[NSMutableArray alloc]init];
    
    self.viewTitle.text = LocalizationKey(@"深度");
    [self.view addSubview:self.tableView];
    self.tableView.separatorColor = [UIColor clearColor];
       
    [self setTableHeaderView];
    [self headRefreshWithScrollerView:self.tableView];

    [self loadDepthInfo];
}

- (void)loadDepthInfo{
    [NewAllNetManager myDepthCompleteHandle:^(id  _Nonnull resPonseObj, int code) {
        if (code) {
            NSInteger codeInt = [resPonseObj[@"code"] intValue];
            if (codeInt == 0) {
                self.dataArr = [[NSMutableArray alloc]init];
                self.dataArr = resPonseObj[@"data"];
            }
            if (self.dataArr.count == 0) {
                self.tableView.ly_emptyView = self.emptyView;
            }
            [self.tableView reloadData];
        }
    }];
}

- (void)setTableHeaderView {
    UIView *headView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kWindowW, 55)];
    self.tableView.tableHeaderView = headView;
    headView.backgroundColor = [UIColor whiteColor];
    
    UILabel *titleLB1 = [[UILabel alloc]init];
    [headView addSubview:titleLB1];
    [titleLB1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(31);
        make.centerY.equalTo(0);
    }];
    titleLB1.textColor = tThreeColor;
    titleLB1.font = kFont(14);
    titleLB1.text = LocalizationKey(@"用户名");
    
    UILabel *titleLB2 = [[UILabel alloc]init];
    [headView addSubview:titleLB2];
    [titleLB2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(0);
        make.centerY.equalTo(0);
    }];
    titleLB2.textColor = tThreeColor;
    titleLB2.font = kFont(14);
    titleLB2.text = LocalizationKey(@"等级");
    titleLB2.hidden = YES;

    UILabel *titleLB3 = [[UILabel alloc]init];
    [headView addSubview:titleLB3];
    [titleLB3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(-31);
        make.centerY.equalTo(0);
    }];
    titleLB3.textColor = tThreeColor;
    titleLB3.font = kFont(15);
    titleLB3.text = LocalizationKey(@"入金(USDT)");
    
}

#pragma mark-下拉刷新数据
- (void)refreshHeaderAction {
    
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return [[self dataArr] count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

   MyNodeShenKuanCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"id"];
   if (cell == nil) {
       cell = [[MyNodeShenKuanCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"id"];
   }
    
    NSDictionary *dataDic = self.dataArr[indexPath.row];
    NSString *numberString = [[NSString stringWithFormat:@"%@",dataDic[@"phone"]] stringByReplacingCharactersInRange:NSMakeRange(3, 4) withString:@"****"];
    cell.nameLB.text = numberString;
    cell.moneyLB.text = [NSString stringWithFormat:@"%@",dataDic[@"amount"]];
    
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 50;
}

- (LYEmptyView *)emptyView {
    if (!_emptyView) {
        _emptyView = [LYEmptyView emptyViewWithImageStr:@"emptyData" titleStr:[[ChangeLanguage bundle] localizedStringForKey:@"NoData" value:nil table:@"English"]];
        _emptyView.titleLabTextColor = tThreeColor;
        _emptyView.titleLabFont = [UIFont systemFontOfSize:19];
        _emptyView.contentViewY = SCREEN_HEIGHT/2.0-100;
    }
    return _emptyView;
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
